package com.zxt.dao;

/**
 * Created by XiaoQiAng on 2015/11/6.
 */
public class MysqlDao {
    public String adminLoginCheck() {
        String sql = "SELECT name,passWord FROM admin WHERE name=? AND `passWord`=?;";
        return sql;
    }

    /**
     * Part One
     * @return
     */
    public String getDepartmentName() {
        String sql = "SELECT name FROM department;";
        return sql;
    }

    public String getAccountName() {
        String sql = "SELECT name FROM account;";
        return sql;
    }

    public String insertDepartment() {
        String sql = "INSERT INTO department (name,description)VALUES(?,?);";
        return sql;
    }

    public String insertAccount() {
        String sql = "INSERT INTO account (name,prise,description,d_id) VALUES (?,?,?,(SELECT id FROM department WHERE name=?));";
        return sql;
    }

    public String insertPerson() {
        String sql = "INSERT INTO person (name,sex,joinYear,joinMonth,joinDay,type,prise,info,d_id,a_id) VALUES (?,?,?,?,?,?,?,?,(SELECT id FROM department WHERE name=?),(SELECT id FROM account WHERE name=?));";
        return sql;
    }

    /**
     * Part Two BasePrise
     * @return
     */
    public String getBasePrise() {
        String sql = "SELECT name from baseprise;";
        return sql;
    }

    public String insertBasePrise() {
        String sql = "INSERT INTO baseprise (name,b_id) VALUES (?,?);";
        return sql;
    }

    public String insertBasePerson() {
        String sql = "INSERT INTO baseperson (type,prise,gprise,info,b_id,a_id) VALUES (?,?,?,?,(SELECT id FROM baseprise WHERE name=?),(SELECT id FROM account WHERE name=?));";
        return sql;
    }

    public String insertBaseThings() {
        String sql = "INSERT INTO basethings (name,company,band,supplier,type,prise,gprise,b_id) VALUES (?,?,?,?,?,?,?,(SELECT id FROM baseprise WHERE name=?));";
        return sql;
    }

    public String insertOtherBaseThings() {
        String sql = "INSERT INTO otherbasethings (name,company,type,prise,info,b_id) VALUES (?,?,?,?,?,(SELECT id FROM baseprise WHERE name=?));";
        return sql;
    }

}
